package com.java.base.exercise.designmode.single;

/**
 * @Author RenPu
 * @Date 2021/6/21 9:32
 * @Version 1.0
 * @Description:
 **/
public class TestSingle {

    public static void main(String[] args) {


        Single_001 instance = Single_001.getInstance();
        Single_001 instance1 = Single_001.getInstance();
//        System.out.println(instance==instance1?"1111单例饿汉式加载测试成功":"11111非指向同一个对象");

        Single_002 instance2 = Single_002.getInstance();
        Single_002 instance3 = Single_002.getInstance();

//        System.out.println(instance2==instance3?"22222单例懒汉式加载测试成功":"22222非指向同一个对象");

        for (int i = 0; i < 1000; i++) {
            new Thread(() -> {
                System.out.println(Single_004.getInstance().hashCode());
            }).start();


        }


    }
}
